<?
//header("Content-Type: text/xml; charset=utf-8");
$caminhoFora ='/home/luizmore/www';
if ($_SERVER['SERVER_NAME'] == "localhost") { 
	$caminhoSite = $DOCUMENT_ROOT;
}else{ 
	$caminhoSite = $caminhoFora;
}
 set_include_path ($caminhoSite."/moreira/admin/scripts/".PATH_SEPARATOR.$caminhoSite."/moreira/admin/".PATH_SEPARATOR.$caminhoSite."/moreira/admin/includes/");
	require "_onStartPage.php";
	
if ( $_POST['acao'] == 1 ){	
	$tb = $objFuncoes->retornaTabelas($tb);
	
	$sql = "	SELECT  
					$fieldShow as nome,
					$fieldName as idVal
				FROM
					$parentTable b
			    WHERE 
					 b.".$fieldName." ";

	$queryAjax = $objDB->DBExecutarSQL( $sql );
	$rsDadosAjax	= $objDB->DBDadosRegistros($queryAjax);
	$xml .= "<select class='formTextField' id='txtV'>";
	foreach($rsDadosAjax as $rsDadoAjax ){
		$xml .= "<option value='".$rsDadoAjax->idVal."'>".utf8_encode($rsDadoAjax->nome)."</option>";
	}
	$xml .= "</select>";
	
	print $xml;
/*CARREGA INSTITUICAO*/	
}else if( $_POST['acao'] == 2){

	$sql = "   SELECT  
					NOME,
					ID_INSTITUICAO
				FROM
					tbl_instituicao
				ORDER BY NOME	";

	$queryAjax = $objDB->DBExecutarSQL( $sql );
	$rsDadosAjax	= $objDB->DBDadosRegistros($queryAjax);
	$xml .= "<option></option>";
	foreach($rsDadosAjax as $rsDadoAjax ){
		$xml .= "<option value='".$rsDadoAjax->ID_INSTITUICAO."'>".utf8_encode($rsDadoAjax->NOME)."</option>";
	}
	
	print $xml;
/*CARREGA CURSOS*/	
}else if( $_POST['acao'] == 3 ){

	$sql = "   SELECT  
					NOME,
					ID_CURSO
				FROM
					tbl_curso
				ORDER BY NOME	";

	$queryAjax = $objDB->DBExecutarSQL( $sql );
	$rsDadosAjax	= $objDB->DBDadosRegistros($queryAjax);
	$xml .= "<option></option>";
	foreach($rsDadosAjax as $rsDadoAjax ){
		$xml .= "<option value='".$rsDadoAjax->ID_CURSO."'>".utf8_encode($rsDadoAjax->NOME)."</option>";
	}
	
	print $xml;
/*CARREGA TURMAS*/	
}else if( $_POST['acao'] == 4 ){

	$sql = "   SELECT  
					NOME,
					ID_TURMA
				FROM
					tbl_turma
				WHERE
					BITSTATUS = 'S'	
				ORDER BY NOME	";

	$queryAjax = $objDB->DBExecutarSQL( $sql );
	$rsDadosAjax	= $objDB->DBDadosRegistros($queryAjax);
	$xml .= "<option></option>";
	foreach($rsDadosAjax as $rsDadoAjax ){
		$xml .= "<option value='".$rsDadoAjax->ID_TURMA."'>".utf8_encode($rsDadoAjax->NOME)."</option>";
	}
	
	print $xml;
}
	
?>